var app = getApp();
var com = require('../../common.js');
Page({
  data: {
    priceValue: '',
    remarks: '',
    password: '',
    statusd: 1
  },
  onLoad: function(options) {
    var _this = this
    com.link(app.link.kinks, {}, function(rep) {
      console.log(rep)
      var info = rep.data.response.bank
      // info.account_number = "****" + info.account_number.substr(info.account_number.length - 4);
      _this.setData({
        info: info,
        price: rep.data.response.balance,
        statusd: 0
      })
    }, "GET")
  },
  allPrice(e) {
    var _this = this
    _this.setData({
      priceValue: _this.data.price.available
    })
  },
  //获取备注信息
  priceRemarks(e) {
    var _this = this,
      i = e.currentTarget.id
    if (i == 1) {
      _this.setData({
        remarks: e.detail.value
      })
    } else if (i == 2) {
      _this.setData({
        password: e.detail.value
      })
    } else {
      _this.setData({
        priceValue: e.detail.value
      })
    }
  },
  onsaveTap() {
    var _this = this
    com.link(app.link.widthpassword, {
      amount: _this.data.priceValue,
      postscript: _this.data.remarks,
      password: _this.data.password
    }, function(res) {
      console.log(res);
      if (res.data.state) {
        wx.showToast({
          title: res.data.message,
        })
        setTimeout(() => {
          wx.navigateBack({
            delta: 1
          })
        }, 1500)
        console.log('提现成功')
      } else {
        wx.showToast({
          title: res.data.message,
          icon: 'none'
        })
      }
    })
  },
  onReady: function() {},
  onShow: function() {},
  onHide: function() {},
  onUnload: function() {},
  onPullDownRefresh: function() {},
  onReachBottom: function() {}
})